<template>
	<view class="content">
		<view class="header">
			<image @click="back" class="back" src="../../static/tian/back.png" mode=""></image>
			<view class="text">{{$t('titleBat.chainRecords')}}</view>
			<view></view>
		</view>
		<view style="height: 104rpx;"></view>
		<view style="background-color: #ffc850;height: 600rpx;">
			<view class="topBox">
				<view class="topBoxL">
					<view class="topBoxLTop">
						{{total}}
					</view>
					<view class="topBoxLBot">
						{{$t('wallet.ExchangeRecordTow')}}
					</view>
				</view>
				<img src="../../static/img/mydao.png" alt="" class="mydao">
			</view>
			<view class="listBox">
				<!-- <view class="list">
					<view class="">{{user_total}} U</view>
					<view class="">{{$t('CrossChainBridge.TotalPersonalPledge')}}</view>
					<img src="../../static/img/a.png" alt="">
				</view> -->
				<view class="list" @click="godetail">
					<view class="">{{user_profit}} U</view>
					<view class="">{{$t('CrossChainBridge.TotalPersonalincome')}}</view>
					<img src="../../static/img/$.png" alt="">
					<image class="righticon" src="../../static/tian/right.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="list2" >
			<view class="down_title">{{$t('CrossChainBridge.FinancialRecord')}}</view>
			<view class="down_none" v-if="detailist.length == 0">
				<img src="../../static/img/none.png" alt="">
				<view class="">{{$t('CrossChainBridge.NoDataYet')}}</view>
			</view>
			
			<view class="item" v-if="detailist.length > 0" v-for="(item,index) in detailist">
				<view class="itemheader" style="margin-bottom: 18rpx;">
					<view class="left">{{item.number}}{{item.currency_name}}</view>
					<view v-if="item.status==0" class="right">
						
						{{$t('first.title61')}}
					</view>
					<view v-if="item.status==1" class="right2">
						{{$t('first.title134')}}
					</view>
				</view>
				<view class="itemheader">
					<view class="left1">
						{{item.created_at}}
					</view>
					<view style="display: flex;justify-content: flex-end;align-items: center;">
						<view class="left1">{{$t('first.title62')}}: <text style="font-weight: bold;">{{item.days - item.return_days}}</text>{{$t('first.title63')}}</view>
						<view class="right1" style="margin-left: 16rpx;">RATE: <text style="font-weight: bold;">{{(item.type.rate * 100).toFixed(2)}}</text>%</view>
					</view>
				</view>
			</view>
			<u-loadmore
				v-if="detailist.length > 0"
				:status="loadmorestatus" 
				:loading-text="$t('first.title120')" 
				:loadmore-text="$t('first.title119')" 
				:nomore-text="$t('first.title121')"
				marginTop="18px"
			/>
			
		</view>
		
	</view>
</template>

<script>
	import {domain} from '../../config/domain.js'
	export default{
		data(){
			return{
				total:'',
				user_total:'',
				user_profit:'',
				detailist:[],
				page:1,
				lastpage:1,
				loadmorestatus:'loadmore'
			}
		},
		onLoad(e) {
			this.userinfo= uni.getStorageSync('userinfo');
			this.getFinaceAccountDetail();
		},
		onReachBottom() {
			this.page++
			if(this.page <= this.lastpage){
				this.loadmorestatus = 'loading'
				var url=domain + 'api/new_finance_logList?page='+this.page;
				var mytype='get';
				uni.request({
					url,
					method: mytype,
					header: {
						'content-type': 'application/x-www-form-urlencoded' ,//自定义请求头信息
						'Lang':uni.getStorageSync('lang'),
						'AUTHORIZATION':this.userinfo.token,
					},
					success: res => {
						this.loadmorestatus = 'loadmore'
						if(res.data.code==0){
							uni.showToast({
								icon:'none',
								title:res.data.msg 
								// duration:10000
							}); 
						}else{
							this.detailist=[...this.detailist,...res.data.data.list.data]
						}
					},
					fail: (err) => {
						this.loadmorestatus = 'loadmore'
						console.log(err)
					},
					complete: () => {
						this.loadmorestatus = 'loadmore'
						setTimeout(function() {
							uni.hideLoading();
						}, 1000);
					}
				});
			}else{
				this.loadmorestatus = 'nomore'
			}
		},
		methods:{
			godetail(){
				uni.navigateTo({
					url:'./chainrecordsdetail'
				})
			},
			back(){
				uni.navigateBack()
			},
			getFinaceAccountDetail(){
				var url=domain + 'api/new_finance_logList?page='+this.page;
				var mytype='get';
			
				uni.request({
					url,
					method: mytype,
					
					header: {
						'content-type': 'application/x-www-form-urlencoded' ,//自定义请求头信息
						'Lang':uni.getStorageSync('lang'),
						'AUTHORIZATION':this.userinfo.token,
					},
					success: res => {
						if(res.data.code==0){
							uni.showToast({
								icon:'none',
								title:res.data.msg 
								// duration:10000
							}); 
						}else{
							this.total = res.data.data.total
							this.user_profit = res.data.data.user_profit
							this.user_total = res.data.data.user_total
							this.detailist=res.data.data.list.data
							this.lastpage=res.data.data.list.last_page
							if(this.lastpage == 1){
								this.loadmorestatus = 'nomore'
							}
						}
					},
					fail: (err) => {
						console.log(err)
					},
					complete: () => {
						setTimeout(function() {
							uni.hideLoading();
						}, 1000);
					}
				});
			},
		}
	}
</script>
<style>
	*{
		margin: 0;
		padding: 0;
		box-sizing: border-box;
	}
	.page{
		width: 100%;
		height: 100%;
		min-height: 100vh;
		background-color: #ecf0f5;
	}
	.header{
		width: 100%;
		height: 104rpx;
		padding: 20rpx;
		position: fixed;
		background-color: #ecf0f5;
		display: flex;
		top: 0;
		left: 0;
		align-items: center;
		justify-content: space-between;
		z-index: 999;
	}
	.back{
		width: 48rpx;
		height: 48rpx;
	}
	.header .text{
		font-size: 36rpx;
		font-family: PingFangSC-Medium,PingFang SC;
		font-weight: 600;
		color: #222;
	}

	.back {
		margin-left: 20rpx;
	}

	.time {
		margin-right: 30rpx;
	}
</style>
<style>
	page {
		/* background-color: #fff */
	}

	.content {
		position: relative;
		overflow: hidden;
	}

	.topBoxL {
		width: 60%;
	}

	.topBoxLTop {
		font-size: 52rpx;
		font-weight: 600;
		color: #0c0c0c;
		margin-bottom: 30rpx;
		word-wrap: break-word;
	}

	.topBox {
		width: 100%;
		padding: 30rpx 0rpx 0rpx 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.topBoxLBot {
		font-size: 30rpx;
	}

	.mydao {
		width: 300rpx;
		height: 300rpx;
	}


	.listBox {
		width: 100%;
		display: flex;
		justify-content: space-around;
	}

	.header {
		width: 100%;
		height: 104rpx;
		padding: 20rpx;
		position: fixed;
		background-color: #ecf0f5;
		display: flex;
		top: 0;
		left: 0;
		align-items: center;
		justify-content: space-between;
		z-index: 999;
	}

	.back {
		width: 48rpx;
		height: 48rpx;
	}

	.header .text {
		font-size: 36rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 600;
		color: #222;
	}

	.list {
		width: 90%;
		height: 160rpx;
		background: #fff;
		box-shadow: 0 18rpx 45rpx 0 rgba(0, 0, 0, .08);
		border-radius: 40rpx;
		padding: 40rpx;
		box-sizing: border-box;
		position: relative;
		overflow: hidden;
	}


	.list2 {
		width: 100%;
		background: #fff;
		border-radius: 40rpx;
		padding: 50rpx;
		box-sizing: border-box;
		margin-top: -80rpx;
		/* position: absolute; */
		/* top: 520rpx;
		z-index: 999; */
	}

	.list view:nth-child(1) {
		font-size: 35rpx;
		font-weight: 700;
		color: #0c0c0c;
		margin-bottom: 20rpx;
	}

	.list view:nth-child(2) {
		font-size: 24rpx;
		color: #909090;
	}

	.list img {
		position: absolute;
		right: 0;
		bottom: 0;
		width: 108rpx;
		height: 86rpx;
	}
	
	.list .righticon{
		position: absolute;
		right: 20rpx;
		top: 20rpx;
		width: 44rpx;
		height: 44rpx;
	}

	.down_title {
		font-size: 38rpx;
		font-weight: 600;
		color: #222;
	}

	.down_none {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 560rpx;
		height: 580rpx;
		margin-top: 10rpx;
	}

	.down_none img {
		width: 402rpx;
		height: 352rpx;
	}

	.down_none view {
		font-size: 25rpx;
		color: #9394bc
	}
	
	
	.item{
		width: 100%;
		height: 146rpx;
		background: #fff;
		box-shadow: 0 0.18667rem 0.42667rem 0 rgb(0 0 0 / 8%);
		border-radius: 32rpx;
		margin-top: 40rpx;
		padding: 36rpx;
		box-sizing: border-box;
	}
	.itemheader{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.itemheader .left{
		font-size: 32rpx;
		font-weight: bold;
		color: #323233;
	}
	.itemheader .left1{
		font-size: 24rpx;
		color: #858587;
	}
	.itemheader .right{
		font-size: 28rpx;
		color: #ffb40f;
	}
	.itemheader .right1{
		font-size: 24rpx;
		color: #858587;
	}
	.itemheader .right2{
		font-size: 24rpx;
		color: #00aa00;
	}
</style>